Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webrtc-adapter

Package Overview
Dependencies
Maintainers
5
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc-adapter

A shim to insulate apps from WebRTC spec changes and browser prefix differences

  • 7.7.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
434K
decreased by-9.72%
Maintainers
5
Weekly downloads
 
Created

What is webrtc-adapter?

The webrtc-adapter npm package is a shim to insulate apps from spec changes and prefix differences in WebRTC APIs. It helps developers write code that works across different browsers by providing a consistent API.

What are webrtc-adapter's main functionalities?

Browser Compatibility

The webrtc-adapter package helps ensure that WebRTC code is compatible across different browsers by normalizing the API differences. This code sample demonstrates how to use the adapter to get browser details.

const adapter = require('webrtc-adapter');
console.log(adapter.browserDetails.browser); // Outputs the browser name
console.log(adapter.browserDetails.version); // Outputs the browser version

Unified API

The webrtc-adapter package provides a unified API for accessing media devices, making it easier to write cross-browser WebRTC applications. This code sample shows how to use the adapter to access the user's media devices.

const adapter = require('webrtc-adapter');
const getUserMedia = navigator.mediaDevices.getUserMedia || navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
getUserMedia({ video: true, audio: true })
  .then(stream => {
    console.log('Got MediaStream:', stream);
  })
  .catch(error => {
    console.error('Error accessing media devices.', error);
  });

Peer Connection

The webrtc-adapter package helps manage peer connections by normalizing the API across different browsers. This code sample demonstrates how to create a peer connection and handle ICE candidates.

const adapter = require('webrtc-adapter');
const pc = new RTCPeerConnection();
pc.onicecandidate = event => {
  if (event.candidate) {
    console.log('New ICE candidate:', event.candidate);
  }
};
pc.createOffer()
  .then(offer => pc.setLocalDescription(offer))
  .then(() => console.log('Offer created and set as local description'))
  .catch(error => console.error('Error creating offer:', error));

Other packages similar to webrtc-adapter

FAQs

Package last updated on 10 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc